package hot100;

public class maxSubArray {
    public int maxSubArray(int[] nums) {
        int max = Integer.MIN_VALUE;
        int currentSum = 0;

        for(int x:nums) {
            currentSum = Math.max(x,currentSum + x);
            max = Math.max(max,currentSum);
        }
        return max;

    }

}
